package com.nononsenseapps.feeder.db.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import arrow.core.const
import com.gitee.wsl.time.now
import com.nononsenseapps.feeder.db.FEED_ITEMS_FEATURE
import com.nononsenseapps.feeder.db.room.ID_UNSET
import kotlinx.datetime.LocalDateTime


@Entity(tableName = FEED_ITEMS_FEATURE.tableName)
data class FeedItemFeature @Ignore constructor(
    @PrimaryKey(autoGenerate = true)
        @ColumnInfo(name = FEED_ITEMS_FEATURE.COL_ID) var id: Long = ID_UNSET,
    @ColumnInfo(name = FEED_ITEMS_FEATURE.COL_TITLE) var title: String = "",
    @ColumnInfo(name = FEED_ITEMS_FEATURE.COL_CREATEDATE, typeAffinity = ColumnInfo.INTEGER) var createDate: LocalDateTime = LocalDateTime.now()
){
    constructor() : this(id = ID_UNSET)

    override fun toString(): String {
        return title
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (this::class != other!!::class) return false

        other as FeedItemFeature

        if (id != other.id) return false

        return true
    }

    override fun hashCode(): Int {
        return id.hashCode()
    }


}